<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div>
            <input type="text" @keyup.enter="add" v-model.trim="username" placeholder="请输入用户名">
            <input type="text"  v-model.number="age" placeholder="请输入年龄">
        </div>
    </div>


    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script>
    <script>
        const vue = new Vue({
            el: '#app',
            data: {
                username: '',
                age: 0
            },
            methods: {
                add(){
                    console.log('用户输入了用户名');
                }
            }
        })
    </script>
</body>
</html>